package controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.Book_Deal;

@WebServlet("/ClassPut")
public class ClassPut extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private Book_Deal deal = new Book_Deal();
    public ClassPut() {
        super();
    }

	protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		res.setCharacterEncoding("utf-8");
		
		String book_imgsrc = req.getParameter("book_imgsrc");
		String book_name = req.getParameter("book_name");
		String typename = req.getParameter("typename");
		String press_name = req.getParameter("press_name");
		String put_id = req.getParameter("put_id");
		String class_id = req.getParameter("class_id");
		String number = req.getParameter("number");
		
		boolean falg = deal.Book_receive(book_imgsrc,book_name,typename,press_name,put_id,class_id,number);
		
		if(falg) {
			res.sendRedirect("/TeachingTest/main?page=book-put&target=3");
		}else {
			res.sendRedirect("/TeachingTest/main?page=book-put&target=3");
		}
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		doGet(req, res);
	}

}
